package com.guoxin.part1.chapter4;

import java.util.HashMap;

/**
 * dead lock
 *
 * @author guoxin
 * @date 2019/8/28
 */
public class HashMapDeadLock {
    private final HashMap<String, String> map = new HashMap<>();

    private void add(String key, String value) {
        map.put(key, value);
    }

    public static void main(String[] args) {
        final HashMapDeadLock hmdl = new HashMapDeadLock();
        for (int i = 0; i < 2; i++) {
            new Thread(() -> {
                for (int j = 0; j < Integer.MAX_VALUE; j++) {
                    hmdl.add(String.valueOf(j), String.valueOf(j));
                }
            }).start();
        }
    }
}
